package org.gridprotectionalliance.oam.proxy

/**
 * Helper class for dealing with connection strings
 */
object ConnectionString {

  def parse(s: String) : Map[String, String] = {
    val pairs = s.split(';')
    pairs.foldLeft(Map.empty[String, String]) { (map, p) =>
      val idx = p.indexOf('=')
      if(idx == -1) throw new IllegalArgumentException("Connection string contains an illegally formatted key/value pair: " + p)
      else {
        val (key, value) = p.splitAt(idx)
        map + (key -> value.tail)
      }
    }
  }

}


